home *** CD-ROM | disk | FTP | other *** search
- class SendAFriend extends MovieClip
- {
- var onEnterFrame;
- var sURL;
- var tfFriendsName;
- var tfFriendsEmail;
- var tfYourName;
- var tfYourEmail;
- var btnSend;
- var btnBack;
- var oEnterLst;
- var mcBlockade;
- var mcYourEmail;
- var mcYourName;
- var mcFriendsEmail;
- var mcFriendsName;
- function SendAFriend()
- {
- super();
- this.onEnterFrame = this.init;
- }
- function init(Void)
- {
- this.onEnterFrame = null;
- this.sURL = Application.sBasePath + "TellAFriend.php";
- this.tfFriendsName.tabIndex = 0;
- this.tfFriendsEmail.tabIndex = 1;
- this.tfYourName.tabIndex = 2;
- this.tfYourEmail.tabIndex = 3;
- this.tfFriendsEmail.restrict = "A-Za-z0-9_.@\\-";
- this.tfYourEmail.restrict = "A-Za-z0-9_.@\\-";
- this.btnSend.onRelease = mx.utils.Delegate.create(this,this.onReleaseSend);
- this.btnBack.onRelease = mx.utils.Delegate.create(this,this.onReleaseBack);
- this.oEnterLst = new Object();
- this.oEnterLst.onKeyDown = mx.utils.Delegate.create(this,this.onPressKey);
- Key.addListener(this.oEnterLst);
- Selection.setFocus(this.tfFriendsName);
- Key.removeListener(Interface.getInstance().oSpaceLst);
- }
- function onReleaseSend(Void)
- {
- if(this.tfFriendsName.length > 0)
- {
- if(this.tfFriendsEmail.length > 0 && this.checkEmail(this.tfFriendsEmail.text))
- {
- if(this.tfYourName.length > 0)
- {
- if(this.tfYourEmail.length > 0 && this.checkEmail(this.tfYourEmail.text))
- {
- this.mcBlockade.gotoAndStop("show");
- var _loc2_ = new LoadVars();
- _loc2_.SENDERNAME = this.tfYourName.text;
- _loc2_.SENDEREMAIL = this.tfYourEmail.text;
- _loc2_.RECEIPIENTNAME = this.tfFriendsName.text;
- _loc2_.RECEIPIENTEMAIL = this.tfFriendsEmail.text;
- _loc2_.MESSAGE = "";
- _loc2_.onLoad = mx.utils.Delegate.create(this,this.onLoadEmail);
- _loc2_.sendAndLoad(this.sURL,_loc2_,"POST");
- Key.removeListener(this.oEnterLst);
- }
- else
- {
- this.mcYourEmail.gotoAndPlay("error");
- Selection.setFocus(this.tfYourEmail);
- Selection.setSelection(0,this.tfYourEmail.length);
- }
- }
- else
- {
- this.mcYourName.gotoAndPlay("error");
- Selection.setFocus(this.tfYourName);
- }
- }
- else
- {
- this.mcFriendsEmail.gotoAndPlay("error");
- Selection.setFocus(this.tfFriendsEmail);
- Selection.setSelection(0,this.tfFriendsEmail.length);
- }
- }
- else
- {
- this.mcFriendsName.gotoAndPlay("error");
- Selection.setFocus(this.tfFriendsName);
- }
- }
- function onLoadEmail(bSuccess)
- {
- if(bSuccess)
- {
- this.mcBlockade.gotoAndPlay("sent");
- }
- else
- {
- this.mcBlockade.gotoAndPlay("error");
- }
- Key.addListener(this.oEnterLst);
- }
- function onPressKey(Void)
- {
- if(Key.isDown(13))
- {
- this.onReleaseSend();
- }
- }
- function checkEmail(sEmail)
- {
- var _loc4_ = sEmail.lastIndexOf(".");
- var _loc2_ = sEmail.indexOf("@");
- var _loc3_ = sEmail.indexOf(" ");
- var _loc5_ = sEmail.lastIndexOf("..");
- if(_loc3_ < 0 && _loc2_ > 0 && _loc2_ + 1 < _loc4_ && _loc5_ == -1)
- {
- return true;
- }
- return false;
- }
- function onReleaseBack(Void)
- {
- Interface.getInstance().onReleaseSendBack();
- }
- }
-